<?php
namespace app\index\controller;

use app\index\controller\Common;
//use app\index\controller\Common;

use think\Controller;

use think\Db;

class Index  extends Common
{
    public function index()
    {
    	if(cache('category'))
    	{
    		$cate=cache('category');
    	}else{
	    		$cate=Db::name('category')->where('pid',0)->select();
	    	foreach ($cate as $k => $v) {
	    		# code...
	    		$cate[$k]['child']=Db::name('category')->where('pid',$v['id'])->select();
	    	}
	    	cache('category',$cate,['expire'=>3600*24]);
	    	
    	}
    		//dump($cate);
			$this->assign('cate',$cate);
	       return $this->fetch();
    	
    }
}
